package airport.server.DAO;

import org.hibernate.Session;
import org.hibernate.Transaction;

import java.util.ArrayList;

/**
 * Created by Romain on 13/02/15.
 */
public abstract class DAO<T> {

	protected Session session;

	protected Transaction tx;

	public void connection() {
		session = HibernateUtil.getSessionFactory().openSession();
		tx = session.beginTransaction();
	}

	public void commitAndClose() {
		tx.commit();
		session.close();
	}

	public abstract ArrayList<T> selectAll();

	public abstract String save(T clazz);

	public abstract String update(T obj);

	public abstract String delete(T clazz);
}
